package com.igeekhome.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.igeekhome.pojo.WorkQualityStatistics;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 工作质量统计 Mapper 接口
 * </p>
 *
 * @author ${author}
 * @since 2021-03-16
 */
public interface WorkQualityStatisticsMapper extends BaseMapper<WorkQualityStatistics> {

    // QueryWrapper qw=new QueryWrapper();
    @Select("select SUM(totalSessionCount) from workload_statistics ${ew.customSqlSegment}")
    int getAll(@Param(Constants.WRAPPER) Wrapper wrapper);

    @Select("select SUM(totalMessageCount) from workload_statistics ${ew.customSqlSegment}")
    int getmessage(@Param(Constants.WRAPPER) Wrapper wrapper);

    @Select("select AVG(1-noReview/effectiveSessionCount) from work_quality_statistics ${ew.customSqlSegment}")
    double getReView(@Param(Constants.WRAPPER) Wrapper wrapper);

    @Select("select COUNT(*) from customer_info ${ew.customSqlSegment}")
    int getCustomer(@Param(Constants.WRAPPER) Wrapper wrapper);

    @Select("SELECT AVG(resolved/effectiveSessionCount) FROM work_quality_statistics ${ew.customSqlSegment}")
    double getSolved(@Param(Constants.WRAPPER) Wrapper wrapper);

    @Select("SELECT AVG(goodReview/(goodReview+mediumReview+noReview)) FROM work_quality_statistics ${ew.customSqlSegment}")
    double getgood(@Param(Constants.WRAPPER) Wrapper wrapper);
}
